# include <bits/stdc++.h>
# define N 1000005
# define lowbit(x) (x&(-x))
using namespace std;
int n,q;
int a[N];
string ss;
vector<int> v[N];
int st[N],tp;
set<int> s;
struct BIT
{
    int sum[N];
    void add(int x)
    {
        for(int i=1;i<=n;i+=lowbit(i))
            sum[i]++;
        for(int i=x+1;i<=n;i+=lowbit(i))
            sum[i]--;
    }
    void del(int x)
    {
        for(int i=1;i<=n;i+=lowbit(i))
            sum[i]--;
        for(int i=x+1;i<=n;i+=lowbit(i))
            sum[i]++;
    }
    int get(int x)
    {
        if(x>n)
            return 0;
        int ans=0;
        for(int i=x;i>0;i-=lowbit(i))
            ans+=sum[i];
        return ans;
    }
}T;
bool ok[N];
int main()
{
    freopen("good.in","r",stdin);
    freopen("good.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>q;
    cin>>ss;
    ss=' '+ss;
    for(int i=1;i<=n;i++)
        if(ss[i]=='0')
            a[i]=-1;
        else
            a[i]=1;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        v[l].push_back(r);
    }
    int res=0;
    st[0]=n+1;
    for(int i=n;i>=1;i--)
    {
        if(a[i]==1)
        {
            if(!tp)
                T.add(i);
            else
            {
                int now=st[tp--];
                T.del(now-1);
                T.add(i);
                auto it=s.lower_bound(now);
                if(it!=s.begin() && it!=s.end())
                {
                    auto it2=it;
                    it2--;
                    if(T.get(*it2)<=T.get(*it))
                        s.erase(it);
                }
            }
            s.insert(i);
        }
        else
        {
            T.del(i);
            T.add(i-1);
            st[++tp]=i;
            int now=T.get(i);
            while(s.size() && T.get(*s.begin())>=now)
                s.erase(s.begin());
            s.insert(i);
        }
        for(auto r:v[i])
        {
            int L=1,R=tp,pos=0;
            while(L<=R)
            {
                int mid=L+R>>1;
                if(st[mid]>r)
                    pos=mid,L=mid+1;
                else
                    R=mid-1;
            }
            int ans=tp-pos;
            auto it=--s.upper_bound(r);
            ans+=max(0,-T.get(*it)+T.get(r+1)+(st[pos]==r+1 && pos));
            res^=ans;
        }
    }
    cout<<res<<endl;
    return 0;
}